<!DOCTYPE HTML>
<html lang="zh_CN">
<head>
<title>&nbsp;</title>
<meta content="text/html;charset=UTF-8" http-equiv="content-type">
</head>
<body>
<div id="home5" class="home5" style="height:350px;width:530px;">
	<form method="POST" style="margin:0;">
		<div style="padding:10px;text-align:right;">
			<div style="display:none;">
				<input name="id">
				<input name="iname" id="iname">
				<input name="country">
				<input name="province">
				<input name="city">
				<input name="county">
			</div>
			<table style="border-collapse:separate; border-spacing:0px 8px;font-size:12px">
			<tr>
                <td style="text-align:right;">简称</td>
                <td>
                    <input name="inameSimple" class="ccrfid-readonly" style="height:25px;width:200px;" id="inameSimple">
                </td>
				<td style="text-align:right;">编号</td>
				<td>
					<input id="sn" name="sn" class="ccrfid-readonly" style="height:25px;width:200px;">
				</td>
			</tr>
			<tr>
				<td style="text-align: right;">全称</td>
			  	<td colspan="3">
			  		<input id="orgId" name="orgId" class="ccrfid-readonly" style="height:25px;width:455px;"></td>
			</tr>
			<tr>
				<td style="text-align:right;">国家</td>
				<td>
					<input name="countryCode" id="countryCode" class="ccrfid-readonly" style="height:25px;width:200px;" id="countryCode">
				</td>
				<td style="text-align:right;">省份</td>
				<td>
					<input name="provinceCode" id="provinceCode" class="ccrfid-readonly" style="height:25px;width:200px;" id="provinceCode">
				</td>
			</tr>
			<tr>
				<td style="text-align:right;">市县</td>
				<td>
					<input name="cityCode" id="cityCode" class="ccrfid-readonly" style="height:25px;width:200px;" id="cityCode">
				</td>
				<td style="text-align:right;">行政区</td>
				<td>
					<input name="countyCode" id="countyCode" class="ccrfid-readonly" style="height:25px;width:200px;" id="countyCode">
				</td>
			</tr>
			<tr>
				<td style="text-align: right;">地址</td>
			  	<td colspan="3">
			  		<input name="address" class="ccrfid-readonly" style="height:25px;width:455px;" id="address"></td>
			</tr>
			<tr>
				<td style="text-align:right;">办公电话</td>
				<td>
					<input name="businessTelephone" class="ccrfid-readonly" style="height:25px;width:200px;"></td>
				<td style="text-align:right;">传真号码</td>
				<td>
					<input name="faxNumber" class="ccrfid-readonly" style="height:25px;width:200px;" id="faxNumber"></td>
			</tr>
			<tr>
				<td style="text-align:right;">联系人</td>
				<td>
					<input name="contactPerson" class="ccrfid-readonly" style="height:25px;width:200px;"></td>
				<td style="text-align:right;">联系电话</td>
				<td>
					<input name="contactTelephone" class="ccrfid-readonly" style="height:25px;width:200px;"></td>
			</tr>
			<tr>
				<td style="text-align:right;">联系手机</td>
				<td>
					<input name="contactPhone" class="ccrfid-readonly" style="height:25px;width:200px;"></td>
				<td style="text-align:right;">电子邮件</td>
				<td>
					<input name="contactEmail" class="ccrfid-readonly" style="height:25px;width:200px;"></td>
			</tr>
			<tr>
				<td style="text-align:right;">经度</td>
				<td>
					<input name="longitude" class="ccrfid-readonly" style="height:25px;width:200px;" id="longitude"></td>
				<td style="text-align:right;">纬度</td>
				<td>
					<input name="latitude" class="ccrfid-readonly" style="height:25px;width:200px;" id="latitude"></td>
			</tr>
			<table>
		</div>
	</form>
</div>
</body>
<!-- <script type="text/javascript" charset="UTF-8" src="/js/common/tree-util.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/common/validatebox-util.js"></script> -->
<script type="text/javascript" charset="UTF-8" src="/js/common/openAddressMap.js"></script>
<script type="text/javascript">
/**
 * 打开成功时
 */
 function whenOpenSuccess(id){
	//系统编号
	$("[name='sn']").textbox({
		required:true,
		readonly:true,
		validType:"evun_isNoSpecialCharacter[]"
	});
	
	$("[name='address']").textbox({
		required:true,
		icons : [ {
			iconCls : 'icon-search',
			handler : function(opt) {
				showMap();
			}
		} ]
	});
	
	$("[name='contactPerson']").textbox({
		required:true
	});
	
    //办公电话 联系电话
    $("[name='businessTelephone'],[name='contactTelephone']").textbox({
        validType:"evun_isTelephone[]"
    });

    //联系手机
    $("[name='contactPhone']").numberbox({
        validType:"evun_isMobile[]"
    });

    //电子邮件
    $("[name='contactEmail']").textbox({
        validType:"evun_isEmail[]"
    });
	//默认聚焦确定按钮
	$("#submit").focus();
	
	//优化校验机制：聚焦时停用校验，失焦时启用校验
	$(".validatebox-text").bind("focus",function(){
		$(this).validatebox("disableValidation");
	});
	
	$(".validatebox-text").bind("blur",function(){
		$(this).validatebox("enableValidation");
	});
	
	//orgCombobox("[name='orgId']","orgId","",{typeId:139},onSelectCallBack);
	
	//国家
	$("[name='countryCode']").combobox({
		editable:false,
		required:true,
		panelHeight:'auto',//自动高度适合
	    method:"GET",
		url:"/syszoning/subset?pid=0",
		valueField:"code",
		textField:"iname",
		onLoadSuccess:function(){
            var country = $("[name='country']").val();
            var province = $("[name='province']").val();
            var city = $("[name='city']").val();
            var county = $("[name='county']").val();
            $('#countryCode').combobox('setText', country);
            $('#provinceCode').combobox('setText', province);
            $('#cityCode').combobox('setText', city);
            $('#countyCode').combobox('setText', county);
            $('#provinceCode').combobox('reload',"/syszoning/subset?pid=" + 1);
		},
		onSelect: function(record){
            debugger;
            $("[name='country']").val(record.iname);
            $("[name='province']").val("");
            $("[name='city']").val("");
            $("[name='county']").val("");
            $('#provinceCode').combobox('clear');
            $('#countyCode').combobox('clear');
            $('#cityCode').combobox('clear');
            $('#provinceCode').combobox('reload',"/syszoning/subset?pid=" + record.id);
		}
	});
	
	// 下拉框选择控件，下拉框的内容是动态查询数据库信息
 	$("[name='provinceCode']").combobox({
 		method:"GET",
		url: null,
		editable:false, //不可编辑状态
		cache: false,
		//panelHeight: 'auto',//自动高度适合
		valueField:"code",
		textField:"iname",
		data:[],
		onSelect: function(record){
            $("[name='province']").val(record.iname);
            $("[name='city']").val("");
            $("[name='county']").val("");
            $('#cityCode').combobox('clear');
            $('#countyCode').combobox('clear');
            $('#cityCode').combobox('reload',"/syszoning/subset?pid=" + record.id);
		}
	}); 
	
	$("[name='cityCode']").combobox({
		method:"GET",
		url: null,
		editable:false, //不可编辑状态
		cache: false,
		panelHeight: 'auto',//自动高度适合
		valueField:"code",
		textField:"iname",
		data:[],
		onSelect: function(record){
            $("[name='city']").val(record.iname);
            $("[name='county']").val("");
            $('#countyCode').combobox('clear');
            $('#countyCode').combobox('reload',"/syszoning/subset?pid=" + record.id);
		}
    });
	
	$("[name='countyCode']").combobox({ 
		method:"GET",
		url: null,
		editable:false, //不可编辑状态
		cache: false,
		panelHeight: 'auto',//自动高度适合
		valueField:"code",
		textField:"iname",
		data:[],
	    onSelect: function(record){
            $("[name='county']").val(record.iname);
        }
	});
	
	$("[name='longitude']").numberbox({});
	$("[name='latitude']").numberbox({});
	$("[name='inameSimple']").textbox({});
	$("[name='faxNumber']").textbox({});
	
	//分页加载工厂
	commonComponent.orgCombogrid({
		id : "orgId",
		initText : $("#iname").val(),
		onSelect : function(index, rowData) {
			$("[name='iname']").val(rowData.iname);
			$("#sn").textbox("setValue", rowData.sn);
		},
		queryParams : {
			typeId : commonComponent.constant.factoryTypeId,
            paramState:4
		}
	});
}

function onSelectCallBack(){
	var t = $('#orgId').combotree('tree');
	var n = t.tree('getSelected');
	$("[name='iname']").val(n.text);
	$.ajax({
	   type: "GET",
	   url:"/sysorg/edit",
	   data:"id=" + n.id,
	   success: function(msg){
	     $("#sn").textbox("setValue", msg.sn);
	   }
	});
}

function whenLoadSuccess(data, operation) {
	/**
	//分页加载工厂
	commonComponent.orgCombogrid({
		id : "orgId",
		initText : $("#iname").val(),
		onSelect : function(index, rowData) {
			$("[name='iname']").val(rowData.iname);
			$("#sn").textbox("setValue", rowData.sn);
		},
		queryParams : {
			typeId : commonComponent.constant.factoryTypeId	
		}
	});
	**/
}
</script>
</html>